package com.dq.controller.subscribe;

import com.dq.controller.in.StaffSubscribeQuery;
import com.dq.controller.in.SubscribePayRequest;
import com.dq.controller.in.request.SubscribeAdd;
import com.dq.domain.subscribe.Subscribe;
import com.dq.exception.customException.AdminException;
import com.dq.service.AllService;
import com.dq.vo.Vo;
import com.dq.vo.baseVo.VO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @Author luchangtong
 * @Date 2020/4/14 17:50
 */
@Api(description = "预约管理")
@RestController
@RequestMapping("/sys/Subscribe/")
public class SysSubscribeController extends AllService {

    @ApiOperation(value = "预约记录",notes = "")
    @PostMapping("list")
    public Vo list(@RequestBody StaffSubscribeQuery staffSubscribeQuery) throws AdminException {

        return subscribeService.list(staffSubscribeQuery);
    }


    @ApiOperation("修改预约状态")
    @PostMapping("changeSubscribeStatus/{id}/{status}")
    public Vo changeSubscribeStatus (@PathVariable Long id, @PathVariable Subscribe.SubscribeStatus status) throws AdminException{
        return subscribeService.changeSubscribeStatus(id,status,"");
    }

    @ApiOperation("取消预约")
    @PostMapping("cancelSubscribe/{id}")
    public Vo cancelSubscribe(@PathVariable Long id) throws AdminException{
        return subscribeService.changeSubscribeStatus(id,Subscribe.SubscribeStatus.cancel,"取消");
    }

    @ApiOperation("预约结账")
    @PostMapping("paySubscribe")
    public Vo paySubscribe (@RequestBody SubscribePayRequest request) throws AdminException{
        return subscribeService.paySubscribe(request);
    }

    @ApiOperation("预约服务")
    @PostMapping("subscribeService")
    public VO subscribeService(@RequestBody SubscribeAdd subscribeAdd) throws AdminException {
        subscribeService.subscribe(subscribeAdd);
        return new Vo(HttpStatus.OK);
    }

}
